package mashibing;


/**
 * synchronized关键字
 *   对某个对象加锁
 * @Author zengxianlong
 * @Date 2021/11/23 11:17
 * @Version 1.0
 */
public class T {
   private int count=10;
   private Object o=new Object();
   public void m(Object o){
      synchronized (o){
         for (int i=0;i<10;i++){
            count++;
            System.out.println(Thread.currentThread().getName()+"count ="+count);
         }

      }
   }

   public static void main(String[] args) {
      T t= new T();
      for (int i=0;i<=10;i++){
         new Thread(()->{
            t.m(Integer.SIZE);
         }).start();
      }

   }

}
